<?php

namespace App\Providers;

use App\Constant\Constant;
use App\Http\Request;
use App\Services\Third\Wechat;
use Illuminate\Support\ServiceProvider;

class WechatServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('Wechat', function ($app) {
            $client = Request::clientType();
            if ($client == Constant::ClientType_MinApp) {
                $appId     = config('common.wechat_minapp_id');
                $appSecret = config('common.wechat_minapp_secret');
                $isMini    = true;
            } else {
                $appId     = config('common.wechat_app_id');
                $appSecret = config('common.wechat_app_secret');
                $isMini    = false;
            }
            return new Wechat($appId, $appSecret, $isMini);
        });
    }

    /**
     * @return string[]
     * @name:boot
     * @author: lisa
     * @datetime: 2021/10/13 9:05
     */
    public function boot()
    {
        return ['Wechat'];
    }
}
